//
//  Building.m
//  Kfangchan
//
//  Created by liran on 14/11/6.
//  Copyright (c) 2014年 Beijing Renjuren Network Technology Co., Ltd. All rights reserved.
//

#import "Building.h"

@implementation Building

-(int)customerDefinitionNum {
    if (self.customerDefinition == nil || self.customerDefinition.length == 0) {
        return 0;
    }
    
    NSMutableString *result = [NSMutableString string];
    NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"\\d" options:0 error:nil];
    
    NSArray *matches = [regex matchesInString:self.customerDefinition options:0 range:NSMakeRange(0, self.customerDefinition.length)];
    for (NSTextCheckingResult *match in matches) {
        NSString* substringForMatch = [self.customerDefinition substringWithRange:match.range];
        [result appendString:substringForMatch];
    }
    
    if (result != nil && result.length > 0) {
        return [result intValue];
    }
    return 0;
}

-(int)payCommissionNum {
    if (self.payCommission == nil || self.payCommission.length == 0) {
        return 0;
    }
    
    NSMutableString *result = [NSMutableString string];
    NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"\\d" options:0 error:nil];
    
    NSArray *matches = [regex matchesInString:self.payCommission options:0 range:NSMakeRange(0, self.payCommission.length)];
    for (NSTextCheckingResult *match in matches) {
        NSString* substringForMatch = [self.payCommission substringWithRange:match.range];
        [result appendString:substringForMatch];
    }
    
    if (result != nil && result.length > 0) {
        return [result intValue];
    }
    return 0;
}

@end

@implementation BuildingList

+ (Class)elementClass {
    return [Building class];
}

@end